export default {
	getPageData() {
		let that = this
		that.$httpRequest.request({
			that,
			url: 'wechat/getAllAddress',
			method: 'get',
			params: {},
			success: res => {
				if (res.code === that.$httpConfig.SUCCESS_CODE) {
					that.list = res.data
				} else {

				}
			}
		})
	},
	submit(item, index) {
		let that = this
		let params = item
		params.isDefault = true
		this.list.forEach((op, i) => {
			if (i !== index) {
				op.isDefault = false
			}
		})
		that.$httpRequest.request({
			that,
			url: 'wechat/editAddress',
			method: 'post',
			params,
			success: res => {
				if (res.code === that.$httpConfig.SUCCESS_CODE) {
					that.$navSkin.goBack();
				} else {

				}
			}
		})
	},
	toCreateAddress() {
		uni.navigateTo({
			url: '/pages/my/createAddress'
		})
	},
	toEdit(id) {
		uni.navigateTo({
			url: '/pages/my/createAddress?id=' + id
		})
	}
}